home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / pc / DirectX SDK / DXSDK / samples / Multimedia / VBSamples / DirectPlay / DXVBMessenger / Client / frmMsgTemplate.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2001-10-08  |  3.9 KB  |  102 lines

  1. VERSION 5.00
  2. Begin VB.Form frmMsgTemplate 
  3.    Caption         =   "Message"
  4.    ClientHeight    =   4665
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   4680
  8.    Icon            =   "frmMsgTemplate.frx":0000
  9.    LinkTopic       =   "Form1"
  10.    ScaleHeight     =   4665
  11.    ScaleWidth      =   4680
  12.    StartUpPosition =   3  'Windows Default
  13.    Begin VB.TextBox txtSendData 
  14.       Height          =   450
  15.       Left            =   -15
  16.       MultiLine       =   -1  'True
  17.       TabIndex        =   0
  18.       Top             =   4155
  19.       Width           =   4635
  20.    End
  21.    Begin VB.TextBox txtConversation 
  22.       Height          =   3915
  23.       Left            =   0
  24.       Locked          =   -1  'True
  25.       MultiLine       =   -1  'True
  26.       ScrollBars      =   3  'Both
  27.       TabIndex        =   1
  28.       Top             =   0
  29.       Width           =   4635
  30.    End
  31. Attribute VB_Name = "frmMsgTemplate"
  32. Attribute VB_GlobalNameSpace = False
  33. Attribute VB_Creatable = False
  34. Attribute VB_PredeclaredId = True
  35. Attribute VB_Exposed = False
  36. Option Explicit
  37. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  38. '  Copyright (C) 1999-2001 Microsoft Corporation.  All Rights Reserved.
  39. '  File:       frmMsgTemplate.frm
  40. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  41. Private msUser As String
  42. 'The username property lets us make sure messages get routed to the right place
  43. Public Property Let UserName(ByVal sUser As String)
  44.     msUser = sUser
  45.     Me.Caption = "Message - " & sUser
  46. End Property
  47. Public Property Get UserName() As String
  48.     UserName = msUser
  49. End Property
  50. Public Sub AddChatMessage(ByVal sChat As String, Optional ByVal fMeTalking As Boolean = False, Optional fNoTalking As Boolean = False)
  51.     If Not fNoTalking Then
  52.         If fMeTalking Then
  53.             sChat = "<" & gsUserName & "> " & sChat
  54.         Else
  55.             sChat = "<" & msUser & "> " & sChat
  56.         End If
  57.     End If
  58.     'Update the chat window first
  59.     txtConversation.Text = txtConversation.Text & sChat & vbCrLf
  60.     'Now limit the text in the window to be 32k
  61.     If Len(txtConversation.Text) > 32767 Then
  62.         txtConversation.Text = Right$(txtConversation.Text, 32767)
  63.     End If
  64.     'Autoscroll the text
  65.     txtConversation.SelStart = Len(txtConversation.Text)
  66. End Sub
  67. Private Sub Form_GotFocus()
  68.     On Error Resume Next
  69.     txtSendData.SetFocus
  70. End Sub
  71. Private Sub Form_Load()
  72.     Me.Caption = "Message - " & msUser
  73. End Sub
  74. Private Sub Form_Resize()
  75.     If Me.WindowState <> vbMinimized Then
  76.         If Me.Height < (100 * Screen.TwipsPerPixelY) Then
  77.             Me.Move Me.Left, Me.Top, Me.Width, (100 * Screen.TwipsPerPixelY)
  78.         Else
  79.             txtConversation.Move Screen.TwipsPerPixelX, Screen.TwipsPerPixelY, Me.Width - (10 * Screen.TwipsPerPixelX), Me.Height - (2 * txtSendData.Height + (8 * Screen.TwipsPerPixelY))
  80.             txtSendData.Move Screen.TwipsPerPixelX, Me.Height - (2 * txtSendData.Height + (1 * Screen.TwipsPerPixelY)), Me.Width - (8 * Screen.TwipsPerPixelX)
  81.         End If
  82.     End If
  83. End Sub
  84. Private Sub txtSendData_KeyPress(KeyAscii As Integer)
  85.     Dim lMsg As Long
  86.     Dim oBuf() As Byte, lOffset As Long
  87.     If KeyAscii = vbKeyReturn Then 'Send this message
  88.         If txtSendData.Text <> vbNullString Then
  89.             lMsg = Msg_SendMessage
  90.             lOffset = NewBuffer(oBuf)
  91.             AddDataToBuffer oBuf, lMsg, LenB(lMsg), lOffset
  92.             AddStringToBuffer oBuf, msUser, lOffset
  93.             AddStringToBuffer oBuf, gsUserName, lOffset
  94.             AddStringToBuffer oBuf, txtSendData.Text, lOffset
  95.             dpc.Send oBuf, 0, 0
  96.             AddChatMessage txtSendData.Text, True
  97.         End If
  98.         KeyAscii = 0
  99.         txtSendData.Text = vbNullString
  100.     End If
  101. End Sub
  102.